package com.advanced.company2;

import java.util.Arrays;

public class Employee implements Comparable<Employee> {

	String name;
	int age;
	String gender;
	String position;
	double salary;
	int id;

	// Comparable接口比较
	@Override
	public int compareTo(Employee o) {
		// 比较年龄
		Employee e = (Employee) o;
		if (this.age < o.age) {
			return -1;
		}
		if (this.age > o.age) {
			return 1;
		}
		return 0;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public double getSalary() {
		return salary;
	}

	public void setSalary(double salary) {
		this.salary = salary;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void show() {
		System.out.println(this.name + "\t" + this.age + "\t" + this.gender + "\t" + this.position + "\t" + this.salary
				+ "\t" + this.id);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		if (id != other.id)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "员工信息： [姓名：" + name + ", 年龄：" + age + ", 性别：" + gender + ", 职务：" + position + ", 薪水：" + salary + ", 工号："
				+ id + "]";
	}

	public Employee() {

	}

	public Employee(String name, int age, String gender, String position, double salary, int id) {
		super();
		this.name = name;
		this.age = age;
		this.gender = gender;
		this.position = position;
		this.salary = salary;
		this.id = id;
	}

}
